package com.example.metadata;

import com.example.metadata.domain.MetaDatabase;
import com.example.metadata.service.MetaBaseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MetaDatabaseController {

    private final MetaBaseService metaBaseService;

    public MetaDatabaseController(MetaBaseService metaBaseService) {
        this.metaBaseService = metaBaseService;
    }

    @PostMapping("/save")
    public String save(@RequestBody MetaDatabase metaDatabase){
        metaBaseService.save(metaDatabase);
        return "success";
    }

    @GetMapping("/query")
    public Iterable<MetaDatabase> query(){
        return metaBaseService.query();
    }

}
